package com.cyt.web.controller.work.kwmanagement;

import cn.hutool.core.util.StrUtil;
import com.cyt.base.enums.BusinessType;
import com.cyt.base.enums.OperatorType;
import com.cyt.base.model.dto.ReturnResult;
import com.cyt.base.util.StringUtils;
import com.cyt.work.kwmanagement.model.vo.KwManagementVo;
import com.cyt.work.kwmanagement.service.KwManagementService;
import com.cyt.sys.aspect.BaseLog;
import com.cyt.web.controller.base.BaseController;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 考务安排表-考务安排表控制层
 *
 * @author han jun
 * @date 2019-11-26 11:15:26
 */
@RestController
public class KwManagementController extends BaseController {

    @Resource
    private KwManagementService kwManagementService;


    /**
     * 统一跳转
     *
     * @param pageName 页面名称
     * @param applyId 应用id
     * @return ModelAndView
     * @author shengQiang Yu
     * @date 2019-08-28 15:17:40
     */
    @RequestMapping("/work/kwmanagement/kwmanagement/{pageName}")
    public ModelAndView goPage(@PathVariable("pageName") String pageName, String applyId) {
        ModelAndView view = new ModelAndView("/work/kwmanagement/kwmanagement/"+pageName);
        view.addObject("applyId",applyId);
        return view;
    }

    /**
     * 分页查询
     *
     * @param kwManagementVo 接受参数对象
     * @param page 当前页面
     * @param limit 页面数量
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:15:26
     */
    @BaseLog(module = "考务安排表", classz = "考务安排表", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwmanagement/page", method = RequestMethod.POST)
    public ReturnResult page(KwManagementVo kwManagementVo, int page, int limit) {
        return kwManagementService.page(kwManagementVo, page, limit);
    }

    /**
     * 跳转添加或编辑界面
     *
     * @param id 主键
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:15:26
     */
    @BaseLog(module = "考务安排表", classz = "考务安排表", methods = "跳转添加或编辑界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwmanagement/getEdit", method = RequestMethod.GET)
    public ModelAndView getEdit(String id) {
        ModelAndView view = new ModelAndView("/work/kwmanagement/kwmanagement/kwManagementEdit");
        if (StringUtils.isNotBlank(id)) {
            view.addObject(kwManagementService.selectByPrimaryKey(id));
        }
        return view;
    }

    /**
     * 保存或更新
     *
     * @param request 请求对象
     * @param kwManagementVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:15:26
     */
    @BaseLog(module = "考务安排表", classz = "考务安排表", methods = "保存或更新对象", businessType = BusinessType.INSERT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwmanagement/addOrUpdate", method = RequestMethod.POST)
    public ReturnResult addOrUpdate(HttpServletRequest request, KwManagementVo kwManagementVo) {
        return kwManagementService.addOrUpdate(kwManagementVo, acceptCurrentUser(request));
    }


    /**
     * 更新当前步骤的接口
     *
     * @param request 请求对象
     * @param kwManagementVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:15:26
     */
    @BaseLog(module = "考务安排表", classz = "考务安排表", methods = "更新当前的步骤", businessType = BusinessType.INSERT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwmanagement/addOrUpdateStop", method = RequestMethod.POST)
    public ReturnResult addOrUpdateStop(HttpServletRequest request, KwManagementVo kwManagementVo) {
        return kwManagementService.addOrUpdateStep(kwManagementVo, acceptCurrentUser(request));
    }


    /**
     * 根据条件逻辑删除
     *
     * @param request 请求对象
     * @param kwManagementVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:15:26
     */
    @BaseLog(module = "考务安排表", classz = "考务安排表", methods = "逻辑删除对象", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwmanagement/remove", method = RequestMethod.GET)
    public ReturnResult remove(HttpServletRequest request, KwManagementVo kwManagementVo) {
        return kwManagementService.remove(kwManagementVo, acceptCurrentUser(request));
    }


    /**
     * 单个对象查询
     *
     * @param kwManagementVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "one查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwmanagement/findOneVo", method = RequestMethod.POST)
    public ReturnResult findOneVo(KwManagementVo kwManagementVo) {
        return new ReturnResult(kwManagementService.findOneVo(kwManagementVo));
    }






    /**
     * 根据条件物理删除
     *
     * @param request 请求对象
     * @param kwManagementVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:15:26
     */
    @BaseLog(module = "考务安排表", classz = "考务安排表", methods = "物理对象对象", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwmanagement/delete", method = RequestMethod.GET)
    public ReturnResult delete(HttpServletRequest request, KwManagementVo kwManagementVo) {
        return kwManagementService.delete(kwManagementVo, acceptCurrentUser(request));
    }







    /**
     * 跳转导入考生的编辑界面
     *
     * @param ksId 考务id
     * @param applyId 应用id
     * @return ModelAndView
     * @author Jun Han
     * @date 2019/12/3 9:38
     */
    @BaseLog(module = "考务安排", classz = "考务安排表", methods = "跳转添加学生界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwstudentmessage/getNewEdit", method = RequestMethod.GET)
    public ModelAndView getEdit(String ksId,String applyId,String parentMenuId) {
        ModelAndView view = new ModelAndView("/work/kwmanagement/kwstudentmessage/kwStudentMessageEdit");
        if (org.apache.commons.lang3.StringUtils.isNotBlank(ksId)) {
            view.addObject(kwManagementService.selectByPrimaryKey(ksId));
        }
        view.addObject("applyId",applyId);
        view.addObject("ksId",ksId);
        view.addObject("parentMenuId",parentMenuId);
        return view;
    }

    /**
     * 跳转基本基本信息界面
     *
     * @param ksId 主键
     * @return ReturnResult
     * @author han jun
     * @date 2019-7-8 17:55:38
     */
    @BaseLog(module = "考务安排", classz = "考务安排表", methods = "跳转基本信息填写界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwmangementEdit", method = RequestMethod.GET)
    public ModelAndView getEditNow(String ksId,String applyId,String parentMenuId) {
        ModelAndView view = new ModelAndView("/work/kwmanagement/kwkcmessage/kwKcMessageEdit");
        if (StrUtil.isNotEmpty(ksId)) {
            view.addObject(kwManagementService.selectByPrimaryKey(ksId));
        }
        view.addObject("applyId",applyId);
        view.addObject("ksId",ksId);
        view.addObject("parentMenuId",parentMenuId);
        return view;
    }

    /**
     * 跳转考场设置界面
     *
     * @param ksId 主键
     * @return ReturnResult
     * @author han jun
     * @date 2019-7-8 17:55:38
     */
    @BaseLog(module = "考务安排", classz = "考务安排表", methods = "跳转考场设置界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwKcSettingEdit", method = RequestMethod.GET)
    public ModelAndView kwKcSettingEdit(String ksId,String applyId,String parentMenuId) {
        ModelAndView view = new ModelAndView("/work/kwmanagement/kwkcsetting/kwKcSettingEdit");
        if (StrUtil.isNotEmpty(ksId)) {
            view.addObject(kwManagementService.selectByPrimaryKey(ksId));
        }
        view.addObject("applyId",applyId);
        view.addObject("ksId",ksId);
        view.addObject("parentMenuId",parentMenuId);
        return view;
    }


    /**
     * 跳转老师设置界面
     *
     * @param ksId 主键
     * @return ReturnResult
     * @author han jun
     * @date 2019-7-8 17:55:38
     */
    @BaseLog(module = "考务安排", classz = "考务安排表", methods = "跳转老师设置界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwKcMessageListEdit", method = RequestMethod.GET)
    public ModelAndView kwKcMessageListEdit(String ksId,String applyId,String parentMenuId) {
        ModelAndView view = new ModelAndView("/work/kwmanagement/kwkcmessage/kwKcMessageList");
        if (StrUtil.isNotEmpty(ksId)) {
            view.addObject(kwManagementService.selectByPrimaryKey(ksId));
        }
        view.addObject("applyId",applyId);
        view.addObject("ksId",ksId);
        view.addObject("parentMenuId",parentMenuId);
        return view;
    }


    /**
     * 跳转考试通知界面
     *
     * @param ksId 主键
     * @return ReturnResult
     * @author han jun
     * @date 2019-7-8 17:55:38
     */
    @BaseLog(module = "考务安排", classz = "考务安排表", methods = "跳转考试通知界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwStudentMessageListEdit", method = RequestMethod.GET)
    public ModelAndView kwStudentMessageListEdit(String ksId,String applyId,String parentMenuId) {
        ModelAndView view = new ModelAndView("/work/kwmanagement/kwstudentmessage/kwStudentMessageList");
        if (StrUtil.isNotEmpty(ksId)) {
            view.addObject(kwManagementService.selectByPrimaryKey(ksId));
        }
        view.addObject("applyId",applyId);
        view.addObject("ksId",ksId);
        view.addObject("parentMenuId",parentMenuId);
        return view;
    }


    /**
     * 跳转考试详情界面
     *
     * @param ksId 主键
     * @return ReturnResult
     * @author han jun
     * @date 2019-7-8 17:55:38
     */
    @BaseLog(module = "考务安排", classz = "考务安排表", methods = "跳转考试详情界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwStudentMessageDetail", method = RequestMethod.GET)
    public ModelAndView kwStudentMessageDetail(String ksId,String applyId,String parentMenuId) {
        ModelAndView view = new ModelAndView("/work/kwmanagement/kwstudentmessage/kwStudentMessageDetail");
        if (StrUtil.isNotEmpty(ksId)) {
            view.addObject(kwManagementService.selectByPrimaryKey(ksId));
        }
        view.addObject("applyId",applyId);
        view.addObject("ksId",ksId);
        view.addObject("parentMenuId",parentMenuId);
        return view;
    }


}